<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script type="text/JavaScript">
       /*
           假如投资的年利率为百分之5,假设从1000到5000块,需要花费多少年.

           1000    1000*1.05
           1050    1000*1.05

       */
      var n = 1000;
      var g;
      var year;
      year=0;
      parseInt(n,g);
      while (true) {
            year++;
            alert(year);
            g=n*0.05;
            n=n+g;
           if (n >= 5000) {
               break;
           }
      }
    </script>
  </head>
  <body></body>
</html>
